package com.itheima.多线程.练习;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

public class Demo4 {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        Myr m=new Myr();
        FutureTask<String> ft1=new FutureTask<>(m);
        FutureTask<String> ft2=new FutureTask<>(m);
        FutureTask<String> ft3=new FutureTask<>(m);
        Thread th1=new Thread(ft1,"张三");
        Thread th2=new Thread(ft2,"李四");
        Thread th3=new Thread(ft3,"王五");
        th1.start();
        th2.start();
        th3.start();
        System.out.println(ft1.get());
        System.out.println(ft2.get());
        System.out.println(ft3.get());

    }
}

class Myr implements Callable<String>{

    @Override
    public String call() throws Exception {

        for (int i = 0; i < 100; i++) {
            System.out.println("表白........."+i);
        }
        return "成功";
    }
}